"""
使用lxml库创建html，解析html优先使用BeautifulSoup，详见02_BeautifulSoup_解析示例.py
"""
from lxml import etree

root = etree.Element('html')
body = etree.Element('body')

root.append(body)
print(etree.tostring(root))

# body添加div子元素
div = etree.SubElement(body, 'div')
print(etree.tostring(root, pretty_print=True).decode())
